package com;
import org.yaml.snakeyaml.Yaml;
import java.io.InputStream;

public class ConfigLoader {
    public static DatabaseConfig loadConfig(String filename) {
        Yaml yaml = new Yaml();
        try (InputStream in = ConfigLoader.class.getClassLoader().getResourceAsStream(filename)) {
            if (in == null) {
                throw new RuntimeException("Config file not found: " + filename);
            }
            return yaml.loadAs(in, DatabaseConfig.class);
        } catch (Exception e) {
            throw new RuntimeException("Failed to load config file: " + filename, e);
        }
    }
}
